#include "MidiEvent.h"

MidiEvent::MidiEvent(uint32_t DeltaTime, uint8_t MidiCode, uint8_t para_1, uint8_t para_2, uint8_t para_3) {
    this->DeltaTime = DeltaTime;
    Code = MidiCode >> 4;
    Channel = MidiCode & 0x0f;
    data.resize(3);
    data[0] = para_1;
    data[1] = para_2;
    data[2] = para_3;
}

MidiEvent::MidiEvent(uint32_t DeltaTime, uint8_t FormatCode, const std::vector<uint8_t> &data) : data(data) {
    this->DeltaTime = DeltaTime;
    Code = FormatCode;
}

MidiEvent::MidiEvent(uint32_t DeltaTime, uint8_t FormatCode, uint8_t type, const std::vector<uint8_t> &data) : data(data) {
    this->DeltaTime = DeltaTime;
    Code = FormatCode;
    Channel = type;
}

std::ostream &operator<<(std::ostream &os, const MidiEvent &event) {
    os << "DeltaTime: " << event.DeltaTime << " Channel: " << (int) event.Channel << " Code: " << (int) event.Code;
    return os;
}
